package com.aierjun.retrofit;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2016/6/30.
 */
public class TestRetrofitActivity  extends AppCompatActivity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Retrofit retrofit=new Retrofit.Builder().baseUrl("http://www.kuaidi100.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        LogisticsService service=retrofit.create(LogisticsService.class);
        Call<LogisticsInfoResponse> callback  = service.getLogisticsInfo("zhongtong","405123024058");

        callback.enqueue(new Callback<LogisticsInfoResponse>() {
            @Override
            public void onResponse(Call<LogisticsInfoResponse> call, Response<LogisticsInfoResponse> response) {
                Log.d("aierjun","call:"+call.toString());
                Log.d("aierjun","response body:"+response.body().toString());
            }

            @Override
            public void onFailure(Call<LogisticsInfoResponse> call, Throwable t) {
                Log.d("aierjun","请求失败");
            }
        });
    }
}
